/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Chart;

import java.util.ArrayList;
import java.util.List;
import me.aviator.entity.Ribbon;
import org.w3c.dom.Element;
import org.w3c.dom.svg.SVGDocument;

/**
 *
 * @author Administrator
 */
public class PieChart3D extends SvgChart{
    private List<String> Lable;//标签，每个扇形区域代表的意义
    private List<Double> dataset;//原始制图数据
    private List<String> piefract;//生成的扇区图
    private Ribbon ribbon;
    private String chartName;
    
    public PieChart3D(String name,List<String> lable,List<Double> dataset, Ribbon r){
        chartName=name;
        this.Lable=lable;
        this.dataset=dataset;
        ribbon=r;
    }
    
    public void setpiefract(ArrayList<String> piefract){
        this.piefract=piefract;
    }    
    
    @Override
    public void draw(Element root,SVGDocument doc){
        Element group=doc.createElement("g");
        if(chartName!=null)
        {
            group.setAttribute("id", chartName);
        }
        int i=0;
        for(;i<piefract.size()-1;i++){
            Element e=doc.createElement("path");
            if(Lable!=null&&!Lable.isEmpty())
            {
                e.setAttribute("id", Lable.get(i));
            }
            e.setAttribute("d", piefract.get(i));
            e.setAttribute("fill", "rgb("+String.format("%d,%d,%d",ribbon.getColorlist().get(i).getRed(),ribbon.getColorlist().get(i).getGreen(),ribbon.getColorlist().get(i).getBlue())+")");
            group.appendChild(e);
        }
        Element e=doc.createElement("path");
        e.setAttribute("id", "");
        e.setAttribute("d", piefract.get(i));
        e.setAttribute("style", "fill:url(#colorRadial)");
        group.appendChild(e);
        root.appendChild(group);
    }
}
